package com.yeban.javase.day02.test06;

import java.sql.SQLOutput;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/10
 */
public class User {

    private String name;
    private String address;
    private String phoneNumber;
    private Order[] orders;
    private int orderCount;

    public User() {
    }

    public  User(String name, String address, String phoneNumber) {
        this.name = name;
        this.address = address;
        this.phoneNumber = phoneNumber;
        this.orders = new Order[10]; // 最多10个订单
        this.orderCount = 0;
    }

    // 下单
    public Order playOrder(long orderNum, int goodsNum){
        System.out.println("用户【" + name + "】下单的单号为：" + orderNum);
        Order order = new Order(orderNum,this,goodsNum);

        if (orderCount < orders.length) {
            orders[orderCount] = order;
            orderCount++;
        }

        return order;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * 设置
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * 获取
     * @return phoneNumber
     */
    public String getPhoneNumber() {
        return phoneNumber;
    }

    /**
     * 设置
     * @param phoneNumber
     */
    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    /**
     * 获取
     * @return orders
     */
    public Order[] getOrders() {
        return orders;
    }

    /**
     * 设置
     * @param orders
     */
    public void setOrders(Order[] orders) {
        this.orders = orders;
    }

    /**
     * 获取
     * @return orderCount
     */
    public int getOrderCount() {
        return orderCount;
    }

    /**
     * 设置
     * @param orderCount
     */
    public void setOrderCount(int orderCount) {
        this.orderCount = orderCount;
    }

    public String toString() {
        return "User{name = " + name + ", address = " + address + ", phoneNumber = " + phoneNumber + ", orders = " + orders + ", orderCount = " + orderCount + "}";
    }
}
